class Entity(object):
    _data = None

    def __init__(self, data = None):
        if hasattr(self, '_default_data'):
            self._data = self._default_data.copy()

            if data is not None:
                for key in data.iterkeys():
                    self._data[key] = data[key]
        else:
            if data is not None:
                self._data = data.copy()
            else:
                self._data = dict()

    def serialize(self):
        raise NotImplementedError("Abstract method")

    def unserialize(self, json):
        raise NotImplementedError("Abstract method")

    def __getitem__(self, key):
        try:
            return self._data[key]
        except KeyError:
            raise AttributeError(key)

    def __setitem__(self, key, value):
        try:
            self._data[key] = value
        except KeyError:
            raise AttributeError(key)
